//获取单词
public class GetWord {

    // 获取字符串中的非字母字符（"单词"）
    public static void getWords(String sentence) {
        // 将字符串按空格分开，得到字母字符
        String[] Parts = sentence.split(" ");
        for (String part : Parts) {
            if (!part.isEmpty()) {
                // 忽略空字符串
                System.out.println(part);
            }
        }

    }

    public static void main(String[] args) {
        String exampleSentence = "Java allows you to play online games, " +
                "chat with people around the world, calculateyour mortgage interest, " +
                "and view images in 3D, just to name a few ";
        //调用获取单词的方法
        getWords(exampleSentence);
    }

}
